import java.util.Arrays;

/**
 * Created with IntelliJ IDEA.
 * User: wenxiwen
 * Date: 2022/3/23
 * Time: 17:42
 * Description: No Description
 */
public class TestDemo {
    /**
     *
     * @param array 四种拷贝方法
     */
    public static void main(String[] args) {
        int[] array = {1,2,3,4,5,6,7};
        int[] ret = array.clone();
        System.out.println(Arrays.toString(ret));
    }
    public static void main6(String[] args) {
        int[] array1 = {1,2,3,4,5,6,7,8};
        int[] array2 = new int[array1.length];
        System.arraycopy(array1,0,array2,0,array1.length);
        System.out.println(Arrays.toString(array2));
    }
    public static void main5(String[] args) {
        int[] array = {1,2,3,4,5,6,7,8};
        int[] ret = Arrays.copyOf(array,2*array.length);
        System.out.println(Arrays.toString(ret));
    }
    public static void main4(String[] args) {
        int[] array = {1,2,3,4,5,6,7,8};
        int[] copy = new int[array.length];

        for(int i = 0;i < array.length;i++){
            copy[i] = array[i];
        }
        System.out.println(Arrays.toString(copy));
        System.out.println(Arrays.toString(array));
    }
    public static void main3(String[] args) {
        int[] arr = {1,2,3,4,5,6,7,8,9};
        int[] arr1 = arr;//arr1指向了arr所指向的对象  两个共用了同一个对象
        arr1[5] = 10;
        System.out.println(Arrays.toString(arr));
    }
    public static void main2(String[] args) {
        int[] arr = {1,2,3,4,5,6,7};
        int[] arr1 = {1,2,3,4,5,6,7};
    }
    public static void main1(String[] args) {
        boolean[] array = {false,true,true,false};
        System.out.println(Arrays.toString(array));
    }
}